package com.sfchen.cloud.controller;

import com.sfchen.cloud.utils.JsonData;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RefreshScope
public class HelloController {


  @Value("${chen.name:'user server hello  not name'}")
  public String  defaultName ;

  @GetMapping(value = {"/", "", "/hello/", "name"})
  public JsonData<Map> hello(String name) {
	return JsonData.buildSuccess(Map.of("name", StringUtils.hasText(name) ? name : defaultName));
  }

}
